<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Replaces\Redis;

use Illuminate\Redis\Connectors\PredisConnector;
use Illuminate\Redis\RedisManager;

class ReplaceRedisManager extends RedisManager
{
    /**
     * Get the connector instance for the current driver.
     *
     * @return \Illuminate\Contracts\Redis\Connector
     */
    protected function connector()
    {
        $customCreator = $this->customCreators[$this->driver] ?? null;

        if ($customCreator) {
            return $customCreator();
        }

        switch ($this->driver) {
            case 'predis':
                return new PredisConnector();
            case 'phpredis':
                return new ReplacePhpRedisConnector();
        }
        throw new \Exception('Not found redis driver ' . $this->driver);
    }
}
